import { Layout, Tree } from 'ant-design-vue'

import treeData from './treeData.js'

export default {
  name: 'indexPage',
  components: {
    ALayout: Layout,
    ALayoutSider: Layout.Sider,
    ALayoutHeader: Layout.Header,
    ALayoutContent: Layout.Content,
    ATree: Tree
  },
  data () {
    return {
      treeData
    }
  },
  methods: {
    // 选中目录节点触发
    selectHandler (res, e) {
      if (e.selectedNodes.length <= 0) {
        return
      }
      
      // 获取跳转的页面
      const to = e.selectedNodes[0].props.to
      console.log(to)
      if (to === 'undefined' || to === 'null' || typeof to !== 'string') {
        return
      }
      
      this.$router.replace({
        name: to
      })
    }
  }
}